package com.wang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wang.entity.UserContract;
import com.wang.entity.UserImage;
import com.wang.service.UserContractService;
import com.wang.mapper.UserContractMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author 25312
* @description 针对表【t_user_contract(用户合同表)】的数据库操作Service实现
* @createDate 2025-04-23 10:16:19
*/
@Service
public class UserContractServiceImpl extends ServiceImpl<UserContractMapper, UserContract>
    implements UserContractService{
    @Autowired
    private UserContractMapper userImageMapper;

    @Override
    public boolean saveOrUpdateUserContract(UserContract userContract) {
        boolean flag = false;
        LambdaQueryWrapper<UserContract> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserContract::getUid,userContract.getUid());
        Long l = userImageMapper.selectCount(wrapper);

        if(l <= 0){
            userContract.setCreateTime(new Date());
            flag = userImageMapper.insert(userContract) >= 1;
        }else{
            userContract.setUpdateTime(new Date());
            flag = userImageMapper.update(userContract,wrapper) >= 1;
        }
        return flag;
    }
}




